export const isObject = (obj)=>{
    return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase() ==='object';
};
export const isUndef = (obj)=>{
    return obj === undefined || obj === null;
};
const HTMLTAG =  'html,body,base,head,link,meta,style,title,' +
'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
'embed,object,param,source,canvas,script,noscript,del,ins,' +
'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
'output,progress,select,textarea,' +
'details,dialog,menu,menuitem,summary,' +
'content,element,shadow,template,blockquote,iframe,tfoot'.split(',');
export function isReservedTag(tag){
    return HTMLTAG.includes(tag);
}
export function normalizeProps(options){
    const res = {};
    if (!options.props){
        return;
    }
    if (Array.isArray(options.props)){
        /*
        ['a-A']
        {'aA': {type: null}}
        */
        let i = options.props.length;
        while(i--){
            const val = options.props[i];
            /*
            <div post-id='1'>
            */
            const name = val.replace(/-(\w)/g, function(_, c){
                return c.toUpperCase();
            })
            res[name] = {type: null};
        }
    }else if (isObject(options.props)){
        /*
        {
            'a-A': Number
        }
        */
        // const keys = Object.keys(options.props);
        for (let key in options.props){
            const val = options.props[key];
            const name = val.replace(/-(\w)/g, function(_, c){
                return c.toUpperCase();
            });
            res[name] = isObject(val) ? val : {type: val}
        }
    }else{
        console.warn(`props只能是数组或者对象类型 ${options.props}`);
    }
    options.props = res;
}



